package com.intech.android.demo.cms.decorators;

import com.intech.android.demo.cms.bo.Group;

import java.util.List;

public class AbonentsGroupDecorator
{
    private Group[] abonentGroups;
    private String firstColumnName;
    private String secondColumnName;
    private String thirdColumnName;
    private String fourthColumnName;
    private String fifthColumnName;
    private String sixthColumnName;
    private String seventhColumnName;
    private String eighthColumnName;

    private String firstColumnDescription;
    private String secondColumnDescription;
    private String thirdColumnDescription;
    private String fourthColumnDescription;
    private String fifthColumnDescription;
    private String sixthColumnDescription;
    private String seventhColumnDescription;
    private String eighthColumnDescription;

    public AbonentsGroupDecorator()
    {

    }

    public AbonentsGroupDecorator(Group[] abonentGroups)
    {
        this.abonentGroups = abonentGroups;
    }

    public AbonentsGroupDecorator(List<Group> abonentGroupList)
    {

        while (abonentGroupList.size() < 8)
        {
            abonentGroupList.add(new Group("Empty"));
        }
        abonentGroups = new Group[8];
        for (int i = 0; i < abonentGroupList.size(); i++)
        {
            abonentGroups[i] = abonentGroupList.get(i);
        }
        firstColumnName = abonentGroups[0].getName();
        secondColumnName = abonentGroups[1].getName();
        thirdColumnName = abonentGroups[2].getName();
        fourthColumnName = abonentGroups[3].getName();
        fifthColumnName = abonentGroups[4].getName();
        sixthColumnName = abonentGroups[5].getName();
        seventhColumnName = abonentGroups[6].getName();
        eighthColumnName = abonentGroups[7].getName();
    }

    private String getColumnDescription(Group group)
    {
        String description = getSex(group.getSex());
        description += getAge(group.getAge());
        description += getARPU(group.getARPU());
        return description;
    }

    private String getARPU(String arpu)
    {
        String ageDescription = " with ARPU ";

        if (arpu.equals("low"))
        {
            return ageDescription += "0-8$";
        }
        if (arpu.equals("med"))
        {
            return ageDescription += "8-15$";
        }
        if (arpu.equals("hi"))
        {
            return ageDescription += "15-30$";
        }
        return ageDescription += "more 30$";
    }


    private String getAge(String age)
    {
        String ageDescription = " aged ";
        if (age.equals("1518"))
        {
            return ageDescription += "1518";
        }
        if (age.equals("1921"))
        {
            return ageDescription += "1921";
        }
        if (age.equals("2227"))
        {
            return ageDescription += "2227";
        }
        if (age.equals("2835"))
        {
            return ageDescription += "2835";
        }
        if (age.equals("3645"))
        {
            return ageDescription += "4645";
        }
        return ageDescription += "45";
    }

    private String getSex(String sex)
    {
        if (sex.equals("M"))
        {
            return "Man";
        }
        return "Women";
    }

    public String getFirstColumnDescription()
    {
        return getColumnDescription(abonentGroups[0]);
    }

    public void setFirstColumnDescription(String firstColumnDescription)
    {
        this.firstColumnDescription = firstColumnDescription;
    }

    public String getSecondColumnDescription()
    {
        return getColumnDescription(abonentGroups[1]);
    }

    public void setSecondColumnDescription(String secondColumnDescription)
    {
        this.secondColumnDescription = secondColumnDescription;
    }

    public String getThirdColumnDescription()
    {
        return getColumnDescription(abonentGroups[2]);
    }

    public void setThirdColumnDescription(String thirdColumnDescription)
    {
        this.thirdColumnDescription = thirdColumnDescription;
    }

    public String getFourthColumnDescription()
    {
        return getColumnDescription(abonentGroups[3]);
    }

    public void setFourthColumnDescription(String fourthColumnDescription)
    {
        this.fourthColumnDescription = fourthColumnDescription;
    }

    public String getFifthColumnDescription()
    {
        return getColumnDescription(abonentGroups[4]);
    }

    public void setFifthColumnDescription(String fifthColumnDescription)
    {
        this.fifthColumnDescription = fifthColumnDescription;
    }

    public String getSixthColumnDescription()
    {
        return getColumnDescription(abonentGroups[5]);
    }

    public void setSixthColumnDescription(String sixthColumnDescription)
    {
        this.sixthColumnDescription = sixthColumnDescription;
    }

    public String getSeventhColumnDescription()
    {
        return getColumnDescription(abonentGroups[6]);
    }

    public void setSeventhColumnDescription(String seventhColumnDescription)
    {
        this.seventhColumnDescription = seventhColumnDescription;
    }

    public String getEighthColumnDescription()
    {
        return getColumnDescription(abonentGroups[7]);
    }

    public void setEighthColumnDescription(String eighthColumnDescription)
    {
        this.eighthColumnDescription = eighthColumnDescription;
    }

    public String getFirstColumnName()
    {
        return firstColumnName;
    }

    public void setFirstColumnName(String firstColumnName)
    {
        this.firstColumnName = firstColumnName;
    }

    public String getSecondColumnName()
    {
        return secondColumnName;
    }

    public void setSecondColumnName(String secondColumnName)
    {
        this.secondColumnName = secondColumnName;
    }

    public String getThirdColumnName()
    {
        return thirdColumnName;
    }

    public void setThirdColumnName(String thirdColumnName)
    {
        this.thirdColumnName = thirdColumnName;
    }

    public String getFourthColumnName()
    {
        return fourthColumnName;
    }

    public void setFourthColumnName(String fourthColumnName)
    {
        this.fourthColumnName = fourthColumnName;
    }

    public String getFifthColumnName()
    {
        return fifthColumnName;
    }

    public void setFifthColumnName(String fifthColumnName)
    {
        this.fifthColumnName = fifthColumnName;
    }

    public String getSixthColumnName()
    {
        return sixthColumnName;
    }

    public void setSixthColumnName(String sixthColumnName)
    {
        this.sixthColumnName = sixthColumnName;
    }

    public String getSeventhColumnName()
    {
        return seventhColumnName;
    }

    public void setSeventhColumnName(String seventhColumnName)
    {
        this.seventhColumnName = seventhColumnName;
    }

    public String getEighthColumnName()
    {
        return eighthColumnName;
    }

    public void setEighthColumnName(String eighthColumnName)
    {
        this.eighthColumnName = eighthColumnName;
    }
}
